﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using CourseManagerModels;
using CourseManagerDAL.Helper;

namespace CourseManagerDAL
{
	//讲师访问类
	public class TeacherService
	{
		//根据账号密码获取用户对象
		public Teacher TeacherLogin(Teacher teacher)
		{
			//封装sql
			string sql = $"select * from Teacher where LoginAccount='{teacher.LoginAccount}' and LoginPwd='{teacher.LoginPwd}'";
			SqlDataReader reader = SQLHelper.GetReader(sql);
			if (reader.Read())
			{
				teacher.TeacherId = (int)reader["TeacherId"];
				teacher.LoginPwd = reader["LoginPwd"].ToString();
				teacher.TeacherName= reader["TeacherName"].ToString();

			}
			else
			{
				teacher = null;
			}
			return teacher;
		}

	}
}
